<template>
  <div class="box-card statistics">
    <el-row :gutter="18" v-if="statisticsData" class="panel-group">
      <el-col :span="4" class="content">
        <div class="item">
          <div class="card-left">
            <div class="card_text">开卡数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.sale_count"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/4893f43d1487c6a2fdcfa61cbaea31b8.png"
            alt="加载失败"
          />
        </div>
      </el-col>
      <el-col :span="4" class="content">
        <div class="item">
          <div class="card-left">
            <div class="card_text">首充数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.sale_save_count"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/4773b65cda5c582cb323f39dc72088fe.png"
            alt="加载失败"
          />
        </div>
      </el-col>
      <el-col :span="4" class="content">
        <div class="item">
          <div class="card-left">
            <div class="card_text">激活数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.sale_open_count"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/49aa6241ea239d090e24d98694f8ddda.png"
            alt="加载失败"
          />
        </div>
      </el-col>
      <el-col :span="4" class="content">
        <div class="item">
          <div class="card-left">
            <div class="card_text">涉诈数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.sale_fraud_count"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/0c10802b3cc8a38e1779c35308f27c4b.png"
            alt="加载失败"
          />
        </div>
      </el-col>
      <el-col :span="4" class="content">
        <div class="item">
          <div class="card-left">
            <div class="card_text">投诉数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.sale_complaint_count"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/4c035327750d5b7322d1cff1dba1e3dd.png"
            alt="加载失败"
          />
        </div>
      </el-col>
      <el-col :span="4" class="content" style="border:none">
        <div class="item">
          <div class="card-left">
            <div class="card_text">子公司数量</div>
            <count-to
              :start-val="0"
              :end-val="statisticsData.company_num"
              :duration="3000"
              class="num"
            />
          </div>
          <img
            src="https://tv.ytuy.cn/uploads/def/20240321/bf6128c01dff95b6dc09b1b342533ed1.png"
            alt="加载失败"
          />
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="18" class="panel-group-count">
      <el-col :span="3" class="card-panel-item">
        <router-link :to="{ path: `${roterPre}` + '/order/list' }">
          <div class="card-panel-count">
            <span
              class="iconfont icon-shangpinguanli"
              style="color: #5CC7C1;"
            ></span>
            <span class="panel-text">渠道推广订单</span>
          </div>
        </router-link>
      </el-col>
      <el-col :span="3" class="card-panel-item">
        <router-link :to="{ path: `${roterPre}` + '/company/list' }">
          <div class="card-panel-count">
            <span
              class="iconfont icon-yonghuguanli"
              style="color: #69C0FD;"
            ></span>
            <span class="panel-text">公司管理</span>
          </div>
        </router-link>
      </el-col>
      <el-col :span="3" class="card-panel-item">
        <router-link :to="{ path: `${roterPre}` + '/staff/staffList' }">
          <div class="card-panel-count">
            <span
              class="iconfont icon-fenxiaoguanli"
              style="color: #B27FEB;"
            ></span>
            <span class="panel-text">员工管理</span>
          </div>
        </router-link>
      </el-col>
      <el-col :span="3" class="card-panel-item">
        <router-link
          :to="{ path: `${roterPre}` + '/statistics/statisticsCompany' }"
        >
          <div class="card-panel-count">
            <span
              class="iconfont icon-duanxinpeizhi"
              style="color: #F0AA0B;"
            ></span>
            <span class="panel-text">子公司排名</span>
          </div>
        </router-link>
      </el-col>
      <el-col :span="3" class="card-panel-item">
        <router-link
          :to="{ path: `${roterPre}` + '/statistics/statisticsStaff' }"
        >
          <div class="card-panel-count">
            <span
              class="iconfont icon-dingdanguanli"
              style="color: #EF9B6F;"
            ></span>
            <span class="panel-text">销售员工排名</span>
          </div>
        </router-link>
      </el-col>
    </el-row>
  </div>
</template>

<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import CountTo from "vue-count-to";
import { roterPre } from "@/settings";
import { dashboardStatistics } from "@/api/statistics";
export default {
  name: "BaseInfo",
  components: {
    CountTo
  },
  data() {
    return {
      statisticsData: {
        sale_count: 0,
        sale_open_count: 0,
        sale_save_count: 0,
        company_num: 1,
        sale_complaint_count: 0,
        sale_fraud_count: 0
      },
      roterPre: roterPre,
      group_id: null
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getdate() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();

      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = year + " 年 " + month + " 月 " + strDate + " 日 ";
      return currentdate;
    },
    getList() {
      this.listLoading = true;
      dashboardStatistics()
        .then(res => {
          if (res.status === 200) {
            this.statisticsData = res.data;
          }
          this.listLoading = false;
        })
        .catch(res => {
          this.listLoading = false;
          this.$message.error(res.message);
        });
    }
  }
};
</script>

<style lang="scss" scoped>
.statistics {
  min-width: 700px;
}

.up,
.el-icon-caret-top {
  color: #f5222d;
  font-size: 12px;
  opacity: 1 !important;
}

.down,
.el-icon-caret-bottom {
  color: #39c15b;
  font-size: 12px;
  opacity: 1;
}

.header {
  &-title {
    font-size: 16px;
    color: #000000;
    font-weight: 500;
  }

  &-time {
    font-size: 12px;
    color: #8c8c8c;
  }
}

.card-panel {
  height: 177px;
  cursor: pointer;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  color: #8c8c8c;
  background: #fff;
  position: relative;
}

.card-panel-description {
  padding: 0 20px;
  margin-top: 19px;

  .card-panel-text {
    line-height: 18px;
    margin-bottom: 12px;
    font-weight: normal;
    align-items: center;
    justify-content: space-between;
    display: flex;

    .card-order {
      color: #303133;
      font-size: 16px;
    }

    .card-date {
      border: 1px solid #6394f9;
      border-radius: 3px;
      color: #6394f9;
      background: #f4f7ff;
      text-align: center;
      line-height: 20px;
      width: 38px;
    }
  }

  .card-panel-num {
    font-size: 30px;
    color: #000;
    font-weight: bold;
  }
}

.card-panel-compared {
  margin: 15px 0;
}

.card-panel-date {
  border-top: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
}

.content {
  &-is {
    opacity: 1%;
  }

  &-title {
    font-size: 14px;
    color: #000000;
    margin-bottom: 5px;
  }

  &-time {
    font-size: 12px;
    color: #8c8c8c;
    margin-bottom: 5px;
  }

  &-number {
    font-size: 30px;
  }

  .content-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

.item {
  display: flex;
  max-width: 268px;
  flex: 1;
  height: 125px;
  padding: 0 15px 0 20px;
  align-items: center;
  background: #ffffff;
  .card-left {
    flex: 1;
    .card_text {
      margin-bottom: 7px;
      font-size: 20px;
      color: #6e7eb8;
    }
    .num {
      font-size: 22px;
    }
  }
  img {
    width: 90px;
    height: 90px;
  }
}
.panel-group-count {
  margin-top: 18px;
  .card-panel-item {
    float: left;
  }
  .card-panel-count {
    background-color: #ffffff;
    border-radius: 4px;
    // width: 90%;
    height: 104px;
    text-align: center;
    padding-top: 20px;
    span {
      display: block;
    }
    .iconfont {
      font-size: 27px;
    }
    .panel-text {
      font-size: 14px;
      color: #303133;
      margin-top: 15px;
    }
  }
}
</style>
